package cn.crism.controller;

import cn.crism.commons.JsonData;
import cn.crism.exception.ParamException;
import cn.crism.param.TestVo;
import cn.crism.utils.BeanValidator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/test")
@Slf4j
public class TestController {

    @ResponseBody
    @RequestMapping("/hello.m")
    public JsonData hello() {
        log.info("hello");
        return JsonData.success("Hello!");
    }

    @ResponseBody
    @RequestMapping("/validate.m")
    public JsonData validate_c(TestVo vo)throws ParamException {
        log.info("validate");
        BeanValidator.check(vo);
        return JsonData.success("Test validate!");
    }
}
